package com.yubest.junit.proxy;

import lombok.AllArgsConstructor;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * jdk 代理类
 *
 * @Author: hweiyu
 * @Date: 2022/10/28 16:12
 */
@AllArgsConstructor
public class JdkProxy implements InvocationHandler {

    private Object target;

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("JdkProxy -> before");
        Object value = method.invoke(this.target, args);
        System.out.println("JdkProxy -> after");
        return value;
    }
}
